<template>
  <common-select
    :options="stateOptions"
    :defaultValue="defaultOption"
    @changeoption="changeOption"
    :allow-clear="false">
  </common-select>
</template>
<script>
import CommonSelect from '@/components/SelfComponents/CommonSelect.vue'
import { mapState } from 'vuex'
export default {
  components: {
    CommonSelect
  },
  computed: {
    ...mapState({
      options: (state) => state.dict.taskEcuUpdateDictCode
    }),
    stateOptions () {
      return [{
        id: '',
        name: this.$t('all')
      }].concat(this.options.map(item => {
        return {
          id: item.value,
          name: item.name
        }
      }))
    }
  },
  data () {
    return {
      defaultOption: ''
    }
  },
  created () {
    this.getPageDictData()
  },
  methods: {
    getPageDictData () {
      ['getTaskEcuUpdateDictCodeData'].forEach(method => {
        this.$store.dispatch(method)
      })
    },
    changeOption (val) {
      this.$emit('changeoption', val)
    }
  }
}
</script>
